/*
 * Copyright 2023-2024, Haiku, Inc. All rights reserved.
 * Distributed under the terms of the MIT License.
 */
#ifndef KERNEL_ARCH_LOONGARCH64_KERNEL_ARGS_H
#define KERNEL_ARCH_LOONGARCH64_KERNEL_ARGS_H

#ifndef KERNEL_BOOT_KERNEL_ARGS_H
#error This file is included from <boot/kernel_args.h> only
#endif

#include <util/FixedWidthPointer.h>
#include <boot/uart.h>

#define _PACKED __attribute__((packed))

#define MAX_VIRTUAL_RANGES_TO_KEEP 32

enum
{
    kPlatformNone,
    kPlatformLoongson,
};

// kernel args
typedef struct
{
    // Virtual address range of RAM physical memory mapping region
    addr_range physMap;

    // The virtual ranges we want to keep in the kernel.
    uint32 num_virtual_ranges_to_keep;
    addr_range virtual_ranges_to_keep[MAX_VIRTUAL_RANGES_TO_KEEP];

    // Platform type
    uint32 machine_platform;

    uint64 timerFrequency; // in Hz

    // All following address are virtual
    FixedWidthPointer<void> acpi_root;
    FixedWidthPointer<void> fdt;

    // LoongArch specific hardware
    addr_range extioi;  // 扩展I/O中断控制器
    addr_range liointc; // 本地I/O中断控制器
    addr_range pch_pic; // PCH平台中断控制器
    addr_range msi;     // 消息信号中断控制器

    uart_info uart;

    uint32 coreIds[SMP_MAX_CPUS];
} _PACKED arch_kernel_args;

#endif /* KERNEL_ARCH_LOONGARCH64_KERNEL_ARGS_H */